<template>
  <!-- 收货启动,记录卸货人 -->
		<div class="ywshouhuo_xhr">

			<van-nav-bar :fixed="true" class="navBar" title="混载解绑" left-arrow @click-left="$router.go(-1)"></van-nav-bar>

				<van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o">
					解除同一托盘的多张入库标签绑定
				</van-notice-bar>

				<div class="goodsFromWarp">

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">入库标签：</div>
								</div>
								<van-field
									 clearable
									 class="skuInput"
									 v-model="editForm.jhrq"
									 placeholder="请填写入库标签"
									 @keyup="onEnter($event,do_inputspbar)"
								 />
								<div class="searchBtn">
									<button :disabled="isdisabled"  @click.stop="searchGoodsBtn1()" >
										<van-icon name="search" size="20" color="#1989fa"  />
									</button>
								</div>
						</div>
				</div>


				<div class="carCardWarp">
					<div class="carCard" v-for="(item,index) in tableData" :key="index">
						<van-row class="goodRow" >
						  <van-col span="24"> <span>单据类型:</span> {{fmartStatus(item.billtype)}}</van-col>
						</van-row>

						<div class="goodsTitleRow">
								<div class="goodsTitleLabel">
									<div class="skuName">商品名称：</div>
								</div>
								<div class="skuNoTitle">
									{{item.subsname}}
								</div>
						</div>

						<div class="goodsTitleRow" style="margin-top: 10px;">
								<div class="goodsTitleLabel">
									<div class="skuName">商品编码：</div>
								</div>
								<div class="skuNoTitle">
									{{item.itemid}}
								</div>
						</div>


						<van-row class="goodRow" style="margin-top: 10px;">
						  <van-col span="12"> <span>箱数:</span> {{item.pack}}</van-col>
						  <van-col span="12"> <span>箱装:</span> {{item.unit}}</van-col>
						</van-row>

						<van-row class="goodRow" style="margin-top: 10px;">
						  <van-col span="12"> <span>散数:</span> {{item.qty}}</van-col>
						  <!-- <van-col span="12"> <span>装车人:</span> {{item.zc}}</van-col> -->
						</van-row>
					</div>
				</div>



				<div class="skuBtn" style="justify-content: flex-end;">
					<van-button type="info" :disabled="isdisabled" @click="baocunClick()">保存</van-button>
				</div>
		</div>

</template>

<script>
import { mapActions } from "vuex";
export default {
  name: 'hunzaijiebang',
  data () {
    return {
			editForm:{
				jhrq:'', //入库标签
				jhrq1:'', //入库标签
				jhrq2:'', //入库标签
				jhrq3:'', //入库标签
				jhrq4:'', //入库标签
			},
			skuRow:'',
			isdisabled:false,
			tableData:[
				{
					subsname:''
				}
			],
			carMessageIsShow:false
    }
  },
  methods: {
		 ...mapActions(["showLoading", "hideLoading"]),
		 fmartStatus(djtype){
				if(djtype == 'SH'){
					return '收货单'
				}else if(djtype == 'DBSH'){
					return '调拨收货单'
				}else if(djtype == 'PSFC'){
					return '配送返仓单'
				}else if(djtype == 'DD'){
					return '收货单'
				}
		 },
		 do_inputspbar(pmtxt){
		 	console.log(pmtxt)  //扫描枪获取的参数
		 	this.editForm.jhrq = pmtxt
		 	this.searchGoodsBtn1()
		 },
		 searchGoodsBtn1(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_shouhuo',
				'i':this.FNULLE([
					'opmode','Y_HZJB_qryshserno',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'jhrq',this.editForm.jhrq,
				])
				}, '入库标签查询',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到入库标签查询")
					console.log(rtn_json_obj)
					_self.tableData = rtn_json_obj
				}
			 });
		 },
		 baocunClick(){
			 if(this.tableData.length == 1){
				 this.editForm.jhrq1 = this.tableData[0].shserno
			 }else if(this.tableData.length == 2){
				 this.editForm.jhrq1 = this.tableData[0].shserno
				 this.editForm.jhrq2 = this.tableData[1].shserno
			 }else if(this.tableData.length == 3){
				 this.editForm.jhrq1 = this.tableData[0].shserno
				 this.editForm.jhrq2 = this.tableData[1].shserno
				 this.editForm.jhrq3 = this.tableData[2].shserno
			 }else if(this.tableData.length == 4){
				 this.editForm.jhrq1 = this.tableData[0].shserno
				 this.editForm.jhrq2 = this.tableData[1].shserno
				 this.editForm.jhrq3 = this.tableData[2].shserno
				 this.editForm.jhrq4 = this.tableData[3].shserno
			 }
			 console.log( this.editForm)
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_shouhuo',
					'i':this.FNULLE([
						'opmode','Y_TPHZ_tphzbd',
						'kqid', this.ryuser.kqid,
						'czyid',this.ryuser.operatorid,
						'jhrq1',this.editForm.jhrq,
						'jhrq2',this.editForm.jhrq1,
						'jhrq3',this.editForm.jhrq2,
						'jhrq4',this.editForm.jhrq3,
					])
					}, '托盘混解除',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						console.log("托盘混解除")
						console.log(rtn_json_obj[0])
						if(rtn_json_obj[0].ret_ret == '0'){
							_self.$toast.fail(rtn_json_obj[0].ret_mess)
							_self.editForm.jhrq = ''
							_self.editForm.jhrq1 = ''
							_self.editForm.jhrq2 = ''
							_self.editForm.jhrq3 = ''
							_self.tableData = []
						}else{
							_self.$dialog.alert({title: '提示',message:rtn_json_obj[0].ret_mess,confirmButtonColor:'#f00'})
						}
					}
			 });

		 },
		 _getSaveHunZaiClick(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_shouhuo',
					'i':this.FNULLE([
						'opmode','Y_TPHZ_tphzbd',
						'kqid', this.ryuser.kqid,
						'czyid',this.ryuser.operatorid,
						'jhrq1',this.editForm.jhrq,
						'jhrq2',this.editForm.jhrq1,
						'jhrq3',this.editForm.jhrq2,
						'jhrq4',this.editForm.jhrq3,
					])
					}, '托盘混载提交',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						console.log("得到托盘混载提交")
						console.log(rtn_json_obj[0])
						if(rtn_json_obj[0].ret_ret == '0'){
							_self.$toast.fail(rtn_json_obj[0].ret_mess)
							_self.editForm.jhrq = ''
							_self.editForm.jhrq1 = ''
							_self.editForm.jhrq2 = ''
							_self.editForm.jhrq3 = ''
							_self.skuRow1 = ''
							_self.skuRow2 = ''
							_self.skuRow3 = ''
							_self.skuRow4 = ''
						}else{
							_self.$toast.fail(rtn_json_obj[0].ret_mess)
						}
					}
			 });
		 }
  },
  components:{

  },
  computed: {
     ryuser: function(){
       return this.GWO(true).gUSER;
     }
  },
  mounted :function(){
    var _self = this; window.GWO().debug=this;
  }
}

</script>
<style scoped lang="scss">
// 引入公共样式
@import '@/assets/css/base.scss';
@import '@/assets/css/input.scss';
.ywshouhuo_xhr{
	padding-top:50px;
	padding-bottom: 50px;
}
.xiehuoren{
	width:100px;
	font-size: 12px;
	margin-left: 10px;
}

.tishiMessage{
	width: 100%;
	height: 30px;
	// background-color: #f40;
	font-size: 13px;
}

.messageConTitle{
	margin-top: 10px;
	margin-bottom: 10px;
}


div.carCardWarp{
	width: 94%;
	margin-left: 3%;
	margin-right: 3%;
	margin-top: 20px;
	font-size: 20px;
	font-weight: bold;
	div.carCard{
		border-left: 5px solid #4998FF;
		box-sizing: border-box;
		padding-left: 10px;
		padding-right: 10px;
		border-radius:5px;
		background-color: #fff;
		padding-top: 10px;
		padding-bottom: 10px;
		margin-bottom:15px;
		div.goodRow{
			margin-bottom:8px;
			span{
				display: inline-block;
				width:100px;
			}
		}
		div.goodsTitleRow{
			display: flex;
			width: 100%;
			div.goodsTitleLabel{
				width: 100px;
			}
			div.skuNoTitle{
				width: calc(100% - 100px);
			}
		}
	}
}

</style>

